﻿using System;
using System.Web.UI.WebControls;
using MedicWeb.MedicService;

namespace MedicWeb.forms {
    public partial class LocalityList : SessionPage {
        protected void Page_Load(object sender, EventArgs e) {
            MainService ms = new MainService();
            Locality[] localityList = ms.GetLocalityList(GetSession(), false);
            foreach (var locality in localityList) {
                var row = new TableRow();
                TableCell cellEdit = new TableCell();
                TableCell cellId = new TableCell();
                TableCell cellRegion = new TableCell();
                TableCell cellLocality = new TableCell();
                
                cellEdit.Controls.Add(new HyperLink() {CssClass = "edit modal", NavigateUrl = ResolveUrl("~/forms/Editors/Directory/LocalityEdit.aspx?id=" + locality.Id) });
                cellEdit.Width = 24;
                cellId.Text = "" + locality.Id;
                cellRegion.Text = locality.Region.Title;
                cellLocality.Text = locality.Title;

                row.Cells.Add(cellEdit);
                row.Cells.Add(createDeleteCell(locality));
                row.Cells.Add(cellId);
                row.Cells.Add(cellRegion);
                row.Cells.Add(cellLocality);

                tblLocalities.Rows.Add(row);
            }
        }
    }
}